<?php
include ("include.php");
$danhba = new class_danhba();
$danhba_cat = new class_danhba_cat();


//Layout
$layout_file = $arr_layout["sub"];
include("html_layout.php");

//print_r ($_SERVER);
if ($_SERVER["REQUEST_METHOD"] == "POST"){
	$s_catid = $_POST['s_catid'];
	$city = $_POST['city'];
}else{
	$s_catid = $_GET['cat_id'];
	$city = $_GET['city'];	
	$zipcode = $_GET['zipcode'];	
}
//echo "city: $city - s_catid: $s_catid<br>";

if($s_catid > 0){
	$cat_id = $s_catid;
}

$str_where = " where 1=1 ";
if($cat_id > 0) $str_where .= " and cat_id='$cat_id' ";
if($city != "") $str_where .= " and city like '%$city%' ";
if($zipcode != "") $str_where .= " and zipcode like '%$zipcode%' ";

$sql = "select * from danhba ".$str_where." order by orders desc, star desc";
//echo "$sql<br>";
$str_content = $danhba->list_item($sql, 1, SP_IMAGES_SMALL_WIDTH, $which_page);
$str_htm = ereg_replace("@noidung@", "$str_content", $str_htm);
$str_htm = ereg_replace("@total@", $danhba->total_website."", $str_htm);

$str_htm = ereg_replace("<!--title_begin", "", $str_htm);
$str_htm = ereg_replace("title_end-->", "", $str_htm);

//list cat
$cat_list= $danhba_cat->lietke_item(3);
$str_htm = ereg_replace("<!--cat_list-->", $cat_list, $str_htm);


//Header Loading - CSS, Meta, Javascript ...
include("html_header.php");

//Body Loading - Date-Time, ...
include("html_body.php");	

$menu_left_id = $arr_tintuc_id[$langid]["shopping"];
//Menu include
include("html_menu.php");

//Modules include
include("modules.php");

print $str_htm;
?>